//
//  SearchDistanceParamsModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/19.
//

#import "SearchDistanceParamsModel.h"
#import "MJExtension.h"

@implementation SearchDistanceParamsModel

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"oriList": @"LatLngModel"};
}

+ (AMapDistanceSearchRequest *)distanceSearch:(NSString *)query {
    SearchDistanceParamsModel *distanceParamsModel = [SearchDistanceParamsModel mj_objectWithKeyValues:query];
    
    AMapDistanceSearchRequest *request = [[AMapDistanceSearchRequest alloc] init];
    NSMutableArray<AMapGeoPoint *> *arrays = [NSMutableArray array];
    for (LatLngModel *latLng in distanceParamsModel.oriList) {
        [arrays addObject:[AMapGeoPoint locationWithLatitude:[latLng.latitude doubleValue]
                                                   longitude:[latLng.longitude doubleValue]]];
    }
    request.origins = arrays;
    request.destination = [AMapGeoPoint locationWithLatitude:[distanceParamsModel.target.latitude doubleValue]
                                                   longitude:[distanceParamsModel.target.longitude doubleValue]];
    request.type = distanceParamsModel.type;
    return request;
}

@end
